﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using SigMIS.Model;


namespace SigMIS.ViewModel.Equipment.EquipParameterVMs
{
    public partial class EquipParameterListVM : BasePagedListVM<EquipParameter_View, EquipParameterSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("EquipParameter", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"Equipment", dialogWidth: 800),
                this.MakeStandardAction("EquipParameter", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "Equipment", dialogWidth: 800),
                this.MakeStandardAction("EquipParameter", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "Equipment", dialogWidth: 800),
                this.MakeStandardAction("EquipParameter", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "Equipment", dialogWidth: 800),
                this.MakeStandardAction("EquipParameter", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "Equipment", dialogWidth: 800),
                this.MakeStandardAction("EquipParameter", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "Equipment", dialogWidth: 800),
                //this.MakeStandardAction("EquipParameter", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "Equipment", dialogWidth: 800),
                //this.MakeStandardAction("EquipParameter", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "Equipment"),
            };
        }


        protected override IEnumerable<IGridColumn<EquipParameter_View>> InitGridHeader()
        {
            return new List<GridColumn<EquipParameter_View>>{
                this.MakeGridHeader(x => x.AtBureau),
                this.MakeGridHeader(x => x.AtSection),
                this.MakeGridHeader(x => x.FileName),
                this.MakeGridHeader(x => x.FileId).SetFormat(FileIdFormat),
                this.MakeGridHeader(x => x.Remark),
                this.MakeGridHeaderAction(width: 200)
            };
        }
        private List<ColumnFormatInfo> FileIdFormat(EquipParameter_View entity, object val)
        {
            return new List<ColumnFormatInfo>
            {
                ColumnFormatInfo.MakeDownloadButton(ButtonTypesEnum.Button,entity.FileId),
                //ColumnFormatInfo.MakeViewButton(ButtonTypesEnum.Button,entity.FileId,640,480),
            };
        }


        public override IOrderedQueryable<EquipParameter_View> GetSearchQuery()
        {
            var query = DC.Set<EquipParameter>()
                .CheckContain(Searcher.AtBureau, x=>x.AtBureau)
                .CheckContain(Searcher.AtSection, x=>x.AtSection)
                .CheckContain(Searcher.FileName, x=>x.FileName)
                .CheckContain(Searcher.Remark, x=>x.Remark)
                .Select(x => new EquipParameter_View
                {
				    ID = x.ID,
                    AtBureau = x.AtBureau,
                    AtSection = x.AtSection,
                    FileName = x.FileName,
                    FileId = x.FileId,
                    Remark = x.Remark,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class EquipParameter_View : EquipParameter{

    }
}
